import { Tag } from 'ant-design-vue';
import type { TableColumn } from '@/components/core/dynamic-table';
import { formatToDateTime } from '@/utils/dateUtil';
import {getEventTypeDoc, getStatusTypeColor, getStatusTypeDoc} from '@/views/dealevent/eventUtils'

export type TableListItem = API.EventUpEntity;
export type TableColumnItem = TableColumn<TableListItem>;

export const baseColumns: TableColumnItem[] = [
  // {
  //   title: '#',
  //   dataIndex: 'eventid',
  //   width: 55,
  //   hideInSearch: true,
  // },
  {
    title: '事件状态',
    width: 80,
    dataIndex: 'eventStatus',
    customRender: ({ record }) => {
      // const enable = ~~record.eventType === 1;
      let status =getStatusTypeDoc(record.eventStatus);
      let statusColor =getStatusTypeColor(record.eventStatus);
      return <Tag color={statusColor}>{status}</Tag>;
    },
    formItemProps: {
      component: 'Select',
      componentProps: {
        placeholder: '请选择事件状态',
        options: [
          {
            label: '驳回中',
            value: 3,
          },
          {
            label: '已办结',
            value: 2,
          },
          {
            label: '处置中',
            value: 1,
          },
          {
            label: '未处置',
            value: 0,
          },
        ],
      },
    },
  },
  {
    title: '事件类型',
    width: 80,
    dataIndex: 'eventType',
    formItemProps: {
      component: 'Select',
      componentProps: {
        placeholder: '请选择事件类型',
        options: [
          {
            label: '帮办',
            value: 0,
          },
          {
            label: '代办',
            value: 1,
          },
        ],
      },
    },
    customRender: ({ record }) => {
      const enable = ~~record.eventType === 1;
      let eventTypeDoc = getEventTypeDoc(record.eventType);
      return <Tag color={enable ? 'green' : 'blue'}>{eventTypeDoc}</Tag>;
    },
  },
  {
    title: '事项名称',
    width: 200,
    dataIndex: 'itemName',
    formItemProps: {
      componentProps: {
        placeholder: '请选择事项名称',
      },
    },
  },
  {
    title: '上报人名',
    width: 80,
    dataIndex: 'upPerson',
    hideInSearch: true,

  },
  {
    title: '上报时间',
    dataIndex: 'upTime',
    width: 120,
    customRender: ({ record }) => {
      return formatToDateTime(record.upTime);
    },
    formItemProps: {
      component: 'RangePicker',
    },
  },
  {
    title: '办结人名',
    width: 80,
    dataIndex: 'endWpsUser',
    hideInSearch: true,

    customRender: ({ record }) => {
      let color = record.endWpsUser ? "green" : "blur"
      const newLocal = "color:" + "#000000";
      return <span style={newLocal}>{record.endWpsUser ? record.endWpsUser : '待办结'}</span>;
    },
  },
  {
    title: '办结时间',
    dataIndex: 'endEventTime',
    hideInSearch: true,
    width: 120,
    customRender: ({ record }) => {
      let color = record.endEventTime ? "green" : "blue"
      const newLocal = "color:" + color;
      return (
        <span style={newLocal}>{record.endEventTime ? formatToDateTime(record.endEventTime) : '待办结'}</span>
      );
    },
  },
];
